import numpy as np
import re
import os
import sys
import pandas as pd
import time

start=time.time()

MAX_INT=sys.maxsize


#Dpath1 txt Dpath2 csv,Dpath3 feature
def to_csv1(Dpath1,Dpath2):
    f=open(Dpath1,'r')
    line = f.readline()  
    list1 = []
    while line:
        a = re.split('[ ;;,:]',line.strip())
        b = a[0:MAX_INT]       # 这是选取需要读取的列
        list1.append(b)  # 将其添加在列表之中
        line = f.readline()
    f.close()

    test=pd.DataFrame(data=list1)

    df=test.rename(columns={0:'order_id',1:'ata',2:'distance',3:'simple_eta',4:'driver_id',5:'slice_id'})


    #df1=pd.read_csv('temp3.csv')
    df1=df
    #df2=df1.sort_values(by='slice_id')
    df2=df1
    slice=df2['slice_id']
    del df2['slice_id']
    df2.insert(1,'slice_id',slice)
    del df2['order_id']
    del df2['driver_id']

    df2.to_csv(Dpath2)

to_csv1('test.txt','test.csv')
end=time.time()
print('时间:',end-start)